package com.tmt.im.manager.config;

import io.minio.MinioClient;
import io.minio.SetBucketLifecycleArgs;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Description TODO
 * @Author wuyi
 * @Date 2024/8/11 11:08
 * @Version 1.0
 **/
@Slf4j
@Configuration
public class MinioConfig {

    // API 端点
    @Value("${minio.endpoint}")
    private String endpoint;

    /**
     * 存储桶名称
     */
    @Value("${minio.bucket}")
    private String bucket;

    // Acess Key
    @Value("${minio.access-key}")
    private String accessKey;

    // Secret Key
    @Value("${minio.secret-key}")
    private String secretKey;

    @Value("${minio.expire-days:3}")
    private int expireDays;

    @Bean
    public MinioClient minioClient() {
        return MinioClient.builder()
                .endpoint(this.endpoint)
                .credentials(this.accessKey, this.secretKey)
                .build();
    }
}
